<template>
  <div>
    <ul>
      <li v-for=" m in  messageArr" :key="m.id">
        <router-link
            :to="{
              name:'xiangqing',
              params:{id:m.id},
              query:{
                title:m.title,
                content:m.content
              }
            }">{{ m.title }}
        </router-link>&nbsp;&nbsp;
        <button @click="pushShow(m)">push查看</button>
        <button @click="replaceShow(m)">replaceShow查看</button>
      </li>
    </ul>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: "Message",
  data() {
    return {
      messageArr: [
        {id: "001", title: '手机', content: "联想"},
        {id: "002", title: '电脑', content: "华为"},
        {id: "003", title: '鼠标', content: "无名"},
      ]
    }
  },
  methods: {
    pushShow(m) {
      this.$router.push({
        name: 'xiangqing',
        params: {id: m.id},
        query: {
          title: m.title,
          content: m.content
        }
        })
    },
    replaceShow(m) {
      this.$router.replace({
        name: 'xiangqing',
        params: {id: m.id},
        query: {
          title: m.title,
          content: m.content
        }
      })
    }
  }
}
</script>

<style scoped>

</style>